package com.freesky.biz.rights.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.freesky.biz.rights.domain.ArrearsDetailEntity;
import com.freesky.biz.rights.domain.ArrearsFileEntity;
import com.freesky.biz.rights.mapper.ArrearsDetailMapper;
import com.freesky.biz.rights.mapper.ArrearsFileMapper;
import com.freesky.biz.rights.service.IArrearsDetailService;
import com.freesky.biz.rights.service.IArrearsFileService;
import com.freesky.common.utils.DictUtils;
import com.freesky.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class ArrearsDetailServiceImpl extends ServiceImpl<ArrearsDetailMapper, ArrearsDetailEntity>  implements IArrearsDetailService {

    @Autowired
    private ArrearsDetailMapper arrearsDetailMapper;

    @Override
    public Page selectDetailPage(Page page, ArrearsDetailEntity entity) {
        Page resultPage = arrearsDetailMapper.selectDetailPage(page,entity);
        List<ArrearsDetailEntity> list = resultPage.getRecords();
        for(int i = 0 ; i < list.size() ; i++){
            ArrearsDetailEntity arrearsDetailEntity = list.get(i);
            String dictLabel = DictUtils.getDictLabel("rights_stock_type",arrearsDetailEntity.getType());
            if(StringUtils.isNotEmpty(dictLabel)) {
                arrearsDetailEntity.setType(dictLabel);
            }
            list.set(i,arrearsDetailEntity);
        }
        resultPage.setRecords(list);
        return resultPage;
    }

    @Override
    public List<ArrearsDetailEntity> selectDetailPage(ArrearsDetailEntity entity) {
        return arrearsDetailMapper.selectDetailPage(entity);
    }

    @Override
    public int deleteBatchByIds(String[] ids) {
        return arrearsDetailMapper.deleteBatchByIds(ids);
    }
}
